package com.zekdot.pkcs3.tool;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Create by zekdot on 18-12-26.
 */
public class PrimeTool {
    //获取安全素数方法定义
    public static String getSafePrime(){
        //String path=this.getClass().getResource().getPath("/");
        //System.out.println(path);
        String cmdStr="/home/zekdot/safe_prime";
        Runtime run=Runtime.getRuntime();
        try{
            Process process=run.exec(cmdStr);
            InputStream in=process.getInputStream();
            InputStreamReader reader=new InputStreamReader(in);
            BufferedReader br = new BufferedReader(reader);
            StringBuffer sb = new StringBuffer();
            String message;
            while((message = br.readLine()) != null) {
                sb.append(message);
            }
            return sb.toString();
        }catch (IOException e){
            e.printStackTrace();
            return "F894A666C60C6531CC3DACF7E931B42B";
        }
    }
    public static void main(String args[]){
        System.out.println(getSafePrime());
    }
}
